package com.chenzhou.service;

import com.chenzhou.dao.GoodsImageDAOImpl;
import com.chenzhou.entity.GoodsImage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.List;

@Service
public class GoodsImageService {

    @Autowired
    private GoodsImageDAOImpl dao;

    public List<GoodsImage> queryGoodImageByGoodsID(Integer goods_id){
        return dao.queryGoodImageByGoodsID(goods_id);
    }

    public int add_GoodIamge(GoodsImage goodsImage){
        return dao.add_GoodIamge(goodsImage);
    }

    public int delete_goodsImage(Integer image_id){
        return dao.delete_goodsImage(image_id);
    }

    public GoodsImage queryGoodsImageByID(Integer image_id){
        return dao.queryqueryGoodImageByImageID(image_id);
    }

    /**
     * 删除nginx下img文件夹中的tup
     * @param path
     */
    public void deleteFile(String path){
        File file = new File(path);
        if(file.exists()) {
            file.delete();
            System.out.println("图片删除成功！！！");
        }
    }
}
